<template>
  <div>
    <!-- 基础信息 -->
    <el-card>
      <template #header>
        <span class="leve2_title">基础信息【遍历数据】</span>
      </template>
      <template #default>
        <el-row :gutter="24" v-loading="loading">
          <el-col
            v-for="(item, i) in BaseDetail"
            :key="i"
            :xs="24"
            :sm="12"
            :md="12"
            :lg="8"
            :xl="8"
          >
            <div class="detail-mode" v-if="baseData">
              <span class="label">{{ item.label }}</span>
              <span
                class="text height"
                v-if="!item.type"
                :title="baseData[item.prop] || '--'"
              >
                {{ baseData[item.prop] || "--" }}
              </span>
              <span class="text" v-else>
                <span
                  v-if="item.prop == 'A_B'"
                  :title="`${baseData.effective_date}-${baseData.expiry_date}`"
                >
                  {{
                    `${DateFormat(baseData.effective_date)} / ${DateFormat(
                      baseData.expiry_date
                    )}`
                  }}
                </span>
                <span v-if="item.prop == 'is_included_tax'">
                  {{ baseData[item.prop] ? "是" : "否" }}
                </span>
              </span>
            </div>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" :lg="16" :xl="16">
            <div class="remark" v-if="baseData">
              <span class="label">备注</span>
              <span class="text height">
                {{ baseData.remark || "--" }}
              </span>
            </div>
          </el-col>
        </el-row>
      </template>
    </el-card>
  </div>
</template>

<script setup>
  /**
   * @import
   */
  import { BaseDetail } from "./components/tools";
  import { DateFormat, FieldFormat } from "/@/utils/utils";
  import detailJSON from "./components/detail.json";

  /**
   * @var
   */

  let baseData = ref(null);
  let loading = ref(false);

  /**
   * @method
   */
  // 获取详情数据
  const _getDetailInfo = async () => {
    loading.value = true;
    try {
      baseData.value = detailJSON;

      setTimeout(() => {
        loading.value = false;
      }, 500);
    } catch (error) {}
  };

  onMounted(() => {
    _getDetailInfo();
  });
</script>

<style scoped lang="scss">
  .height {
    display: inline-block;
    max-height: 48px;
    overflow-y: auto;
  }

  .remark {
    display: flex;

    .label {
      display: inline-block;
      width: 122px;
      text-align: right;
      font-size: 14px;
      color: #606266;
      margin-right: 10px;
    }

    .text {
      flex: 1;
      border: 1px solid #c0c0c0;
      color: #a9a9a9;
      border-radius: 4px;
      padding: 0px 10px;
      height: 40px;
      overflow-y: auto;
    }
  }
</style>
